home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 7
/
Apprentice-Release7.iso
/
Source Code
/
Pascal
/
Applications
/
TCPExample
/
PNL Libraries
/
MyAssertions.p
< prev
next >
Wrap
Text File
|
1997-06-20
|
2KB
|
79 lines
unit MyAssertions;
interface
uses
Types;
{$ifc undefined do_debug}
{$setc do_debug := 1}
{$endc}
{$ifc not do_debug}
{$definec Assert(b)}
{$definec SafeDebugStr(s)}
{$definec AssertValidPtr(p)}
{$definec AssertValidPtrNil(p)}
{$definec AssertValidHandle(p)}
{$definec AssertValidHandleNil(p)}
{$elsec}
{$definec Assert(b) AssertCode(b)}
{$definec SafeDebugStr(b) DebugStr(s)}
{$definec AssertValidPtr(p) AssertValidPtrCode(p)}
{$definec AssertValidPtrNil(p) AssertValidPtrNilCode(p)}
{$definec AssertValidHandle(p) AssertValidHandleCode(p)}
{$definec AssertValidHandleNil(p) AssertValidHandleNilCode(p)}
{$endc}
{$ifc do_debug}
procedure AssertCode (b: boolean);
procedure AssertValidPtrCode (p: univ Ptr);
procedure AssertValidPtrNilCode (p: univ Ptr);
procedure AssertValidHandleCode (hhhh: univ Handle);
procedure AssertValidHandleNilCode (hhhh: univ Handle);
{$endc}
implementation
uses
Memory;
{$ifc do_debug}
procedure AssertCode (b: boolean);
begin
if not b then begin
DebugStr('Assert Failed;sc;hc');
end;
end;
procedure AssertValidPtrCode (p: univ Ptr);
begin
Assert((p <> nil) & (not odd(ord4(p))));
end;
procedure AssertValidPtrNilCode (p: univ Ptr);
begin
if p <> nil then begin
AssertValidPtr(p);
end;
end;
procedure AssertValidHandleCode (hhhh: univ Handle);
begin
AssertValidPtr(hhhh);
AssertValidPtr(hhhh^);
Assert(RecoverHandle(hhhh^) = hhhh);
end;
procedure AssertValidHandleNilCode (hhhh: univ Handle);
begin
if hhhh <> nil then begin
AssertValidHandle(hhhh);
end;
end;
{$endc}
end.